#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+2;
int f[N],a[N],n,l,cnt=0,ans=0,d[N];vector<int>b,c;bool vis[N];
inline int calc()
{
    int res=0;b.clear();c.clear();
    for(int i=1;i<=n;++i){
        if(vis[i]==1)b.push_back(a[i]);
    else c.push_back(a[i]);}
    //for(int i=0;i<b.size();++i)cout<<b[i]<<' ';putchar(10);
    //for(int i=0;i<c.size();++i)cout<<c[i]<<' ';putchar(10);
    for(int i=1;i<b.size();++i)
        if(b[i]==b[i-1])res+=b[i];
    for(int i=1;i<c.size();++i)
        if(c[i]==c[i-1])res+=c[i];
    return res;
}
inline void dfs(int d)
{
    if(d>n)
    {
        int k=calc();
        if(ans<k)ans=k;
    }
    else
    {
        vis[d]=1;dfs(d+1);
        vis[d]=0;dfs(d+1);
    }
}
queue<int>q1,q2;
inline void solve()
{
    cin>>n;ans=0;
    for(int i=1;i<=n;++i)cin>>a[i];
    dfs(1);cout<<ans<<endl;
}
signed main()
{
    freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
    int _;cin>>_;
    while(_--)solve();
    fclose(stdin);
	fclose(stdout);
    return 0;
}
